package module;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

import service.CountryService;
import service.CountryServiceImpl;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Singleton;

import dao.CountryDAO;
import dao.jdo.CountryDAOImpl;

public class ServiceModule implements Module {
	
	@Provides
	@Singleton
	public PersistenceManagerFactory providePersistenceManagerFactory() {
		return JDOHelper.getPersistenceManagerFactory("transactions-optional"); 
	}
	
	@Provides
	public PersistenceManager providePersistenceManager(PersistenceManagerFactory pmf) {
		return pmf.getPersistenceManager();
	}
	
	@Override
	public void configure(Binder binder) {
		
		binder.bind(CountryService.class).to(CountryServiceImpl.class);
		
		binder.bind(CountryDAO.class).to(CountryDAOImpl.class);
		
	}

}
